package com.xz;

/**
 * @author XZ
 * @create 2021-04-21 10:22
 * https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/
 */
public class _83_删除排序链表中的重复元素 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode prev = head;
        if (prev != null) {
            while (prev.next != null) {
                int val = prev.val;
                if (prev.next.val == val)
                    prev.next = prev.next.next;
                else
                    prev = prev.next;
            }
        }
        return head;
    }
}
